package org.performancetracker.jdbc4;

import java.sql.*;

/**
 * @author: jaronschut
 */

public abstract class AbstractMonitoringStatement implements Statement {

    /**
     * To override in any subclass.
     *
     * @return
     */
    abstract protected Statement getRealStatement();

    /**
     * To override in any subclass.
     *
     * @return
     */
    abstract protected Connection getRealConnection();


    // Methods of Statement
    
    public ResultSet executeQuery(String sql) throws SQLException {
        return getRealStatement().executeQuery(sql);
    }

    public int executeUpdate(String sql) throws SQLException {
        return getRealStatement().executeUpdate(sql);
    }

    public void close() throws SQLException {
        getRealStatement().close();
    }

    public int getMaxFieldSize() throws SQLException {
        return getRealStatement().getMaxFieldSize();
    }

    public void setMaxFieldSize(int max) throws SQLException {
        getRealStatement().setMaxFieldSize(max);
    }

    public int getMaxRows() throws SQLException {
        return getRealStatement().getMaxRows();
    }

    public void setMaxRows(int max) throws SQLException {
        getRealStatement().setMaxRows(max);
    }

    public void setEscapeProcessing(boolean enable) throws SQLException {
        getRealStatement().setEscapeProcessing(enable);
    }

    public int getQueryTimeout() throws SQLException {
        return getRealStatement().getQueryTimeout();
    }

    public void setQueryTimeout(int seconds) throws SQLException {
        getRealStatement().setQueryTimeout(seconds);
    }

    public void cancel() throws SQLException {
        getRealStatement().cancel();
    }

    public SQLWarning getWarnings() throws SQLException {
        return getRealStatement().getWarnings();
    }

    public void clearWarnings() throws SQLException {
        getRealStatement().clearWarnings();
    }

    public void setCursorName(String name) throws SQLException {
        getRealStatement().setCursorName(name);
    }

    public boolean execute(String sql) throws SQLException {
        return getRealStatement().execute(sql);
    }

    public ResultSet getResultSet() throws SQLException {
        return getRealStatement().getResultSet();
    }

    public int getUpdateCount() throws SQLException {
        return getRealStatement().getUpdateCount();
    }

    public boolean getMoreResults() throws SQLException {
        return getRealStatement().getMoreResults();
    }

    public void setFetchDirection(int direction) throws SQLException {
        getRealStatement().setFetchDirection(direction);
    }

    public int getFetchDirection() throws SQLException {
        return getRealStatement().getFetchDirection();
    }

    public void setFetchSize(int rows) throws SQLException {
        getRealStatement().setFetchSize(rows);
    }

    public int getFetchSize() throws SQLException {
        return getRealStatement().getFetchSize();
    }

    public int getResultSetConcurrency() throws SQLException {
        return getRealStatement().getResultSetConcurrency();
    }

    public int getResultSetType() throws SQLException {
        return getRealStatement().getResultSetType();
    }

    public void addBatch(String sql) throws SQLException {
        getRealStatement().addBatch(sql);
    }

    public void clearBatch() throws SQLException {
        getRealStatement().clearBatch();
    }

    public int[] executeBatch() throws SQLException {
        return getRealStatement().executeBatch();
    }

    public Connection getConnection() throws SQLException {
        return getRealConnection();
    }

    public boolean getMoreResults(int current) throws SQLException {
        return getRealStatement().getMoreResults(current);
    }

    public ResultSet getGeneratedKeys() throws SQLException {
        return getRealStatement().getGeneratedKeys();
    }

    public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
        return getRealStatement().executeUpdate(sql, autoGeneratedKeys);
    }

    public int executeUpdate(String sql, int[] columnIndexes) throws SQLException {
        return getRealStatement().executeUpdate(sql, columnIndexes);
    }

    public int executeUpdate(String sql, String[] columnNames) throws SQLException {
        return getRealStatement().executeUpdate(sql, columnNames);
    }

    public boolean execute(String sql, int autoGeneratedKeys) throws SQLException {
        return getRealStatement().execute(sql, autoGeneratedKeys);
    }

    public boolean execute(String sql, int[] columnIndexes) throws SQLException {
        return getRealStatement().execute(sql, columnIndexes);
    }

    public boolean execute(String sql, String[] columnNames) throws SQLException {
        return getRealStatement().execute(sql, columnNames);
    }

    public int getResultSetHoldability() throws SQLException {
        return getRealStatement().getResultSetHoldability();
    }
}
